thermostat6 2.2.1
Loading...
Searching...
No Matches
thermostat6


Thermostat 6 Click

Thermostat 6 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Jul 2024.
  • Type : ADC/I2C type

Software Support

Example Description

This example demonstrates the use of Thermostat 6 Click board by reading the temperature level set using an on-board potentiometer and the temperature from the NTC Thermistor 10k Cylindrical Probe (B57500M0103A005) which is connected to the input, and also displaying the relay state. If the set temperature level is lower than the temperature read from NTC, then the relay switches ON.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Thermostat6

Example Key Functions

  • thermostat6_cfg_setup Config Object Initialization function.
    void thermostat6_cfg_setup(thermostat6_cfg_t *cfg)
    Thermostat 6 configuration object setup function.
    Thermostat 6 Click configuration object.
    Definition thermostat6.h:132
  • thermostat6_init Initialization function.
    err_t thermostat6_init(thermostat6_t *ctx, thermostat6_cfg_t *cfg)
    Thermostat 6 initialization function.
    Thermostat 6 Click context object.
    Definition thermostat6.h:116
  • thermostat6_get_adc_v_avg This function reads and averages the ADC voltage for a desired number of samples.
    err_t thermostat6_get_adc_v_avg ( thermostat6_t *ctx, float *voltage, uint16_t num_samples );
    err_t thermostat6_get_adc_v_avg(thermostat6_t *ctx, float *voltage, uint16_t num_samples)
    Thermostat 6 get adc voltage average function.
  • thermostat6_get_an_pin_v_avg This function reads and averages the AN pin voltage for a desired number of samples.
    err_t thermostat6_get_an_pin_v_avg ( thermostat6_t *ctx, float *voltage, uint16_t num_samples );
    err_t thermostat6_get_an_pin_v_avg(thermostat6_t *ctx, float *voltage, uint16_t num_samples)
    Thermostat 6 get AN pin voltage function.
  • thermostat6_get_temperature This function calculates temperature in degrees Celsius based on a voltage input using the NTC Thermistor 10k Cylindrical Probe (B57500M0103A005) R/T characteristics map.
    float thermostat6_get_temperature ( float voltage );
    float thermostat6_get_temperature(float voltage)
    Thermostat 6 get temperature function.

Application Init

Initializes the driver and logger.

void application_init ( void )
{
log_cfg_t log_cfg;
thermostat6_cfg_t thermostat6_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
thermostat6_cfg_setup( &thermostat6_cfg );
THERMOSTAT6_MAP_MIKROBUS( thermostat6_cfg, MIKROBUS_1 );
err_t init_flag = thermostat6_init( &thermostat6, &thermostat6_cfg );
if ( ( ADC_ERROR == init_flag ) || ( I2C_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define THERMOSTAT6_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition thermostat6.h:102
void application_init(void)
Definition main.c:34

Application Task

Reads the temperature level set using an on-board potentiometer and the temperature from the NTC Thermistor 10k Cylindrical Probe (B57500M0103A005) connected to the input, and displays the relay state. If the set temperature level is lower than the temperature read from NTC, then the relay switches ON.

void application_task ( void )
{
float voltage = 0;
{
log_printf( &logger, " Set temperature : %.2f[degC]\r\n", thermostat6_get_temperature ( voltage ) );
}
{
log_printf( &logger, " Read temperature : %.2f[degC]\r\n", thermostat6_get_temperature ( voltage ) );
}
if ( thermostat6_get_relay_pin ( &thermostat6 ) )
{
log_printf( &logger, " Set temperature is lower than read temperature! Relay: ON\r\n\n" );
}
else
{
log_printf( &logger, " Set temperature is higher than read temperature! Relay: OFF\r\n\n" );
}
Delay_ms ( 1000 );
}
#define THERMOSTAT6_ADC_NUM_SAMPLES_50
Definition thermostat6.h:77
uint8_t thermostat6_get_relay_pin(thermostat6_t *ctx)
Thermostat 6 get relay pin function.
void application_task(void)
Definition main.c:65
@ THERMOSTAT6_OK
Definition thermostat6.h:152

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.